package com.uclocation.DAO;

import java.util.HashMap;

import android.location.Location;

import com.uclocation.DTO.UCLocation;

/**
 * 
 * @author Rico
 * Our DAO stub.  This implements the methods from the DAO interface.  Retrieves and Inserts data to our Database.
 */
public class UCLocationDAOStub implements IUCLocationDAO {

	@Override
 public UCLocation selectUCLocationn(String LocationName) throws Exception {
		//checks for the expected value of Teachers
		if (LocationName.equalsIgnoreCase("Teachers")){
			//Make an instance of UCLocation
			UCLocation ucLocation = new UCLocation();
			//Create a Location object
			Location location = new Location("stubProvider");
			//set the attriubutes of UCLocation instance
			ucLocation.setLocation(location);
			ucLocation.setUCLocationName("Teachers");
			ucLocation.setLocationpic(null);
			return ucLocation;
		}else {
			throw new Exception("Use Teachers as the UCLocation name Foo!");
		}

	}

	@Override
	public void AddUCLocation(UCLocation location) throws Exception {
		//When writing to the database, I am checking for 2 things: A good location and a good Location name.
		//Location name is good when its not empty or null. Location is good only when it can provide some type of cordinates
		//to lead the user to the desired destination.  As of today, I'm only testing if location is Not null, but I am doing
		//further research to find a more accurate test of how to validate a location.  NOTE: boolean methods of this class does
		// not seem to cut it :(
		if (location.getLocation()!=null && location.getUCLocationName()!=null && !location.getUCLocationName().equals("")){
			//This is where I would persist the UCLocation object to the database
			
		}else {
			throw new Exception ("Bad Location or Location Name");
		}

	}

	@Override
	public HashMap<String, UCLocation> SelectAllUCLocation() {
		UCLocation ucLocation = new UCLocation();
		//Create a Location object
		Location location = new Location("stubProvider");
		//set the attriubutes of UCLocation instance
		ucLocation.setLocation(location);
		ucLocation.setUCLocationName("Teachers");
		ucLocation.setLocationpic(null);
		HashMap<String, UCLocation> allUCLocations = new HashMap<String, UCLocation>();
		allUCLocations.put("Teachers", ucLocation);
		return allUCLocations;
	}

}
